/*
    在Home页面中使用Redux中的store
    1.使用react-redux提供的高阶组件connect()
    2.使用react-redux提供的高阶组件 hooks api
*/
import * as React from 'react'

import { useAppDispatch, useAppSelector } from '../../hooks'
import { addCount,subCount,getList } from '../../store/actions/study'
import { useEffect } from 'react'
export default props=>{
    const count=useAppSelector(store=>store.study.count)
    const list=useAppSelector(store=>store.study.list)
    const dispatch=useAppDispatch()//是视图和store打交道的唯一方式
    // useEffect(() => {
    //     // let data={
    //     //     page:1,
    //     //     tab:'',
    //     //     limit:5
    //     // }
    //     dispatch(getList({}))
    //     return () => { }
    // })
    return(
        <div>
            <h1>我是首页</h1>
            <h1>{count}</h1>
            <hr />
            {/* <div>
                {
                    list.map(ele => (
                        <div key={ele.id}>{ele.title}</div>
                    ))
                }
            </div> */}
            <button onClick={() => dispatch(addCount(2))}>+</button>
            <button onClick={() => dispatch(subCount(3))}>-</button>
        </div>
    )
}